#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
set<int> ans;
bool is_prime(int x) {
  if (x < 2) return false;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
void dfs(int cnt, int sum) {
  if (cnt) {
    int x = sum, res = sum;
    x /= 10;
    while (x) res = res * 10 + x % 10, x /= 10;
    if (is_prime(res)) ans.insert(res);
  }
  if (cnt >= 4) return;
  rep(i, 0, 9) {
    if (cnt == 0 && i % 2 == 0) continue;
    dfs(cnt + 1, sum * 10 + i);
  }
}
void init() {
  ans.insert(2);
  ans.insert(11);
  dfs(0, 0);
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  init();
  int a, b;
  cin >> a >> b;
  for (int x : ans) {
    if (x >= a && x <= b) cout << x << endl;
  }
  return 0;
}